package com.enbatis.mybatisplugs.controller;

import com.enbatis.mybatisplugs.base.BaseController;
import com.enbatis.mybatisplugs.commons.sql.Wrapper;
import com.enbatis.mybatisplugs.commons.utils.ResultReturn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.enbatis.mybatisplugs.entity.TBank;
import com.enbatis.mybatisplugs.service.TBankService;


import java.util.List;

@RestController
@RequestMapping("v1/t_bank")
public class TBankController extends BaseController {

@Autowired
private TBankService tBankService;


    @PostMapping("/add")
    public ResultReturn<TBank> add(@RequestBody TBank tBank){
        return  success(tBankService.insert(tBank));
    }


    @DeleteMapping("/delete")
    public ResultReturn<Integer> delete(@RequestParam("id") Long id){
        return success(tBankService.deleteById(id));
    }


    @PutMapping("/{id}")
    public  ResultReturn<Integer> update(@PathVariable("id") Long id,@RequestBody TBank tBank){
        tBank.setId(id);
        return success(tBankService.updateById(tBank));
    }


    @GetMapping("/{id}")
    public ResultReturn<TBank> get(@PathVariable("id") Long id) {
        return success(tBankService.getById(id));
    }


    @GetMapping("/list")
    public ResultReturn<List<TBank>> getList(TBank tBank){
        return success(tBankService.list(new Wrapper<>(tBank)));
    }

}
